{include file="public/header"/}
{include file="public/left"/}
      
      
    <div class="content">
        <div class="crumbs clr">系统管理 > 菜单管理 <span class="red">> 功能管理</span>
        {if isset($fun['id'])}
          <span class="red">> 编辑</span>
        {else /}
          <span class="red">> 新建</span>
        {/if}
        </div>
        <div class="whiteBox">
          {if isset($fun['id'])}
            <p class="tittle">编辑功能</p>
          {else /}
            <p class="tittle">新建功能</p>
          {/if}
          <table class="addTab mb20">
            <tr>
              <td>选择菜单：</td>
              <td>
                <select name="menu" id="menu">
                  {volist name="list" id='item' key="key"}
                    <option value="{$item.id}" 
                    {if isset($item['pid']) &&  $item['pid'] eq 0 }disabled{/if}

                    {if isset($item['id']) &&  $item['id'] eq $menuid }selected{/if}
                    >
                    {$item.html}{$item.menu_name}</option>
                  {/volist}
                </select>
              </td>
            </tr>
            <tr>
              <td>功能名称：</td>
              <td><input type="text" name="permissions_name" placeholder="请输入功能名称" value="{$fun.permissions_name|default=''}"></td>
            </tr>
            <tr>
              <td>功能代码：</td>
              <td><input type="text" name="permissions_tag" placeholder="请输入功能代码" value="{$fun.permissions_tag|default=''}"></td>
            </tr>
            <tr>
              <td valign="top">描　　述：</td>
              <td>
                <textarea class="loadArea" id="permissions_remark" placeholder="请输入功能描述">{$fun.permissions_remark|default=''}</textarea>
              </td>
            </tr>
            <tr>
              <td></td>
              <td align="right"><span class="greyBtn return">返回</span><span class="redBtn ml15 mr50 save">保存</span></td>
            </tr>
          </table>
        </div>
        
    </div>

   {include file="public/footer"/}


<script type="text/javascript">
//返回
$('.return').on('click',function() {
  window.history.back();
});

$('.save').on('click',function(){
  var menuid="{$menuid}";
  var funid="{$funid}";
   var permissions_name = $('input[name="permissions_name"]').val();
   if ($.trim(permissions_name)=='') {
        layer.alert('请输入功能名称');
        return false;
   }
  var menuid = $('#menu option:selected').val();
  var permissions_tag = $('input[name="permissions_tag"]').val();
   if ($.trim(permissions_tag)=='') {
        layer.alert('请输入功能代码');
        return false;
   }
   var permissions_remark = $('#permissions_remark').val();
    $.post("{:url('admin/menu/editFunAjax')}", {
      funid : funid,
      permissions_name : permissions_name,
      menuid : menuid,
      permissions_tag : permissions_tag,
      permissions_remark:permissions_remark,
    }, function(data){
      if(data.code==1){
        layer.alert(data.msg, function(index){
          location.href = "{:url('admin/menu/fun')}?menuid="+menuid;
        });
      }else if(data.code==2){
        layer.alert(data.msg);
        return false;
      }else if(data.code==3){
        layer.alert(data.msg, function(index){
          location.href = "{:url('admin/menu/fun')}?menuid="+menuid;
        });
      }else{
        layer.alert(data.msg);
        return false;
      }
    }, 'json');
});
</script>
</body>
</html>
    